import scrapy


class QuotesSpider(scrapy.Spider):

    name = 'quotes'
    start_urls = ['http://quotes.toscrape.com/']
    allowed_domains = ['quotes.toscrape.com']

    def parse(self, response):
        for quote in response.css('div.quote'):
            content = quote.css('span.text::text').extract_first()
            author = quote.css('small.author::text').extract_first()
            tags = quote.css('meta.keywords::attr(content)').extract_first()
            yield dict(content=content, author=author, tags=tags)

        # follow all links
        for a in response.css('a'):
            yield response.follow(a, callback=self.parse)
